<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CustomerModel extends Model
{
    /**
     * 与模型关联的表名
     * @var string
     */
    protected $table = 'customer';

    /**
     * 不能被批量赋值的属性
     * @var array
     */
    protected $guarded = [];

    /**
     * 表明模型是否应该被打上时间戳
     * @var bool
     */
    public $timestamps = false;

    /**
     * 只查询状态正常 并且在线的客户
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeOnline($query)
    {
        return $query->where('status', 1)->where('is_online', 1);
    }

    /**
     * 查询正常状态用户
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeStatus($query)
    {
        return $query->where('status', 1);
    }
}
